package com.zq.englishlearnserve.handler;

import cn.dev33.satoken.exception.NotLoginException;
import com.zq.englishlearnserve.common.entity.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler
    public AjaxResult NoLoginException(NotLoginException e) {
        e.printStackTrace();
        return AjaxResult.notLogin(e.getMessage());
    }

    @ExceptionHandler
    public AjaxResult handlerException(Exception e) {
        e.printStackTrace();
        return AjaxResult.error(e.getMessage());
    }
}
